package com.gitee.huanminabc.utils_tools.config_refresh.controller;

import com.gitee.huanminabc.nullchain.common.NullResult;
import com.gitee.huanminabc.utils_tools.config_refresh.event.ConfigChangeEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 配置刷新
 */
@RestController
@RequestMapping("/config")
public class ConfigRefreshController {

    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;

    @GetMapping("/refresh")
    public NullResult<Boolean> refresh(@RequestParam("key") String key, @RequestParam("value") String value) {
        applicationEventPublisher.publishEvent(new ConfigChangeEvent("ConfigRefreshController->refresh", key, value));
        return NullResult.success(true);
    }


}
